HOW I USE
Theres two types of way i use hash tables to store data. Now I'll use an example to explain both ways. The example I'll use is codeing from my own channel protection. FIRST WAY The first way is , a single data word that defines something in the feature in my script. Meaning for example in my own channel protection, the edit field where someone would define how many texts before the feature kicks/bans user for flooding. I store this in the main hash table i use. Kinda like the variables section of mirc Example: on *:dialog:jacp:edit:*:{ When someone types in the edit field. this auto writes to the hash table named system. And it adds the item name "cp.t.count" and the data associated with the item, which is whatever is in that edit field. The system.update is my alias to save the hash table. Read the section related to saving to see more information on that. To return this information , on my init event for the channel protection, i have the line below in this event to add the information into the edit field again. did -a jacp 21 $hget(system,cp.t.count) You should already know about $hget, if not go back and read the previous section. If i wished to delete this item from the hash table all together, I would just type the following or have this line on a button event in a dialog. /hdel system cp.t.count You don't need to type the data associated with the item to delete, just the item you wish to delete. SECOND WAY The second way i use hash tables is, say in my channel protection, i have a channels list that this feature will protect. So i have a line in my main hash table for this and it reads like below ITEM: cp.chans DATA: chan1 chan2 chan3 As you can see, i have more than one field in my data information here. Hense it's not as simple to adjust this item line as it is with the above way. I use 3 aliases to do the following , one allows me to add channel, one allows me to delete channel and one allows me to input information into a listbox alias cp.add.chan { This alias above as you can see, sets a temp variable called %cur , with the data stored in the item marked cp.chans Then i set another temp variable called %new.chans . This contains the current listed channels stored in the variable %cur and also the new channel that has been inputed in the edit field within the dialog. Then i add the new information to the hash table named system You will notice i don't delete previous information, thats cause i rarely have to delete a line from a hash table. As when you readd, it just auto removes previous information stored in cp.chans item line and adds the new information into there the cp.get.chans is the alias i use to return the information associated with the cp.chans item line and that is shown below alias cp.get.chans { Now you see that %cur temp variable is set with the channel list again. Then i use a while loop along with $gettok to return the information. You can read about while loops and $gettok in mircs own help file. But you do have the above alias you can copy and paste into your remote and change to suit your needs. When I wish to delete a channel from my list , I use the alias below to do so alias cp.del.chan { Yet again, i set the temp variable %cur but this time i also set another variable %rem . This is the line that I have selected in the listbox which gets set here Then i use $remove command to remove the information stored in %rem from the channel list stored in %cur . Then obviouslly i readd to hash table and return the new information threw my cp.get.chans alias
|
---|